#include <QGuiApplication>
#include <QQmlApplicationEngine>

#include <QLocale>
#include <QTranslator>
#include <QQmlContext>
#include <QIcon>
#include "TransObj.h"
#include "main_thread.h"
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    qmlRegisterType<Gemini>("TransObj",1,0,"TransObj");
    app.setWindowIcon(QIcon(":/icons/app_icon.png"));
//    qmlRegisterType<Main_Thread>("main_thread",1,0,"task_brake");
    QTranslator translator;
    const QStringList uiLanguages = QLocale::system().uiLanguages();
    for (const QString &locale : uiLanguages) {
        const QString baseName = "untitled2_" + QLocale(locale).name();
        if (translator.load(":/i18n/" + baseName)) {
            app.installTranslator(&translator);
            break;
        }
    }
    Main_Thread task_brake;
    QQmlApplicationEngine engine;
    engine.rootContext()->setContextProperty("task_brake",&task_brake);
    engine.addImportPath("qrc:/imports");
    engine.addImportPath("qrc:/content");
//    const QUrl url("qrc:/content/App.qml");
    const QUrl url("qrc:/FAST CONTROL/main.qml");
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                     &app, [url](QObject *obj, const QUrl &objUrl) {
        if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
    }, Qt::QueuedConnection);
    engine.load(url);
    if (engine.rootObjects().isEmpty())
        return -1;

//    task_brake.start();
    return app.exec();
}
